const path = require('path')
const http = require('http')
const fs = require('fs')
const url = require('url')


const echoIndex = function () {
  let html = `<!DOCTYPE html>
            <html lang="en">
            <head>
              <meta charset="UTF-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <title>记忆法</title>
            </head>
            <body>
              <ol id="context">
                ${htmlFiles.map(n => {
                  return '<li><a href="./'+(n.index - 1)+'">' + n.name + '</a></li>'
                }).join('')}
              </ol>

            </body>
            </html>`
            console.log('html', html);
  return html
}

const port = 3399
const hostname = 'localhost'
const server = http.createServer((req, res) => {
  
  res.setHeader('Content-Type', 'text/html; charset=utf-8')
  res.end('没有数据')

  // fs.readFile(htmlFiles[0].path,'utf8',(err,fileContent)=>{
  //     if(err) {
  //         res.end('Error')
  //     }else {
  //         res.end(fileContent)
  //     }
  // })
})

server.listen(port, () => {
  console.log('\x1b[33m%s\x1b[0m',`服务器运行在 http://${hostname}:${port}/`)
})

